
Ext.define('MyDesktop.module.ProcureManager',{
	extend:'Ext.ux.desktop.Module',
	id:'procure-manager-win',
	init:function(){
		this.launcher = {
			text:'采购管理',
			iconCls:'accordion'
		}
	},
	
	createPanel : function(){
		var panelPanel = Ext.create('Ext.Panel', {
			
				title:'panel',
				html:'我是一个panel'
			});
			
		return panelPanel;
	},
	

	
	createWindow:function(){
		var desktop = this.app.getDesktop();
        var win = desktop.getWindow('procure-manager-win');
        if(!win)
        {
        	win = desktop.createWindow({
        		id:'procure-manager-win',
        		title:'采购管理',
        		width:800,
        		height:500,
        		layout: 'border',
        		items:[{
        			region:'west',
        			title:'导航',
        			width:150,
        			split:true,
        			collapsible:true,
        			floatable: false,
        			layout:{
        			  type:'vbox',
        			  padding:'5',
        			  align:'stretch'
        		    },
        			defaults:{margins:'0 0 5 0'},
        			items:[{
        				xtype:'button',
        				text:'供应商管理',
        				handler:function()
        				{
        				 addTab("供应商管理",Ext.create('A4.view.desktop.procuremanager.SupplierManager'));
        				}
        			},{
        				xtype:'button',
        				text:'建档表管理',
        				handler:function()
        				{
        				  addTab("建档表管理",Ext.create('A4.view.desktop.procuremanager.FileCreateManager'));
        				}
        			},{
        				xtype:'button',
        				text:'改档表管理',
        				handler:function()
        				{
        				  addTab("改档表管理",Ext.create('A4.view.desktop.procuremanager.FileUpdateManager'));
        				}
        			},{
        				xtype:'button',
        				text:'进货单管理',
        				handler:function()
        				{
        				addTab("进货单管理",Ext.create('A4.view.desktop.procuremanager.PurchaseManager'));
        				}
        			},{
        				xtype:'button',
        				text:'退货单管理',
        				handler:function()
        				{
        				  addTab("退货单管理",Ext.create('A4.view.desktop.procuremanager.UnPurchaseManager'));
        				}
        			}]
        		},
        		{
	    			region:'center',
	    			xtype:'tabpanel',
	    			resizeTabs:true,
	    			id:'tabPanel'
	    			
        		}]
        		
        	});
        }
        return win;
	}
	
});


function addTab(title,obj)
{
	
	var tabPanel = Ext.getCmp('tabPanel'); 
	var ishave = true; 
	
	
	tabPanel.items.each(function (tab) {
		if (tab.title == title) { 
			ishave = false;
			tabPanel.setActiveTab(tab);
		}
	});
	
	
	if (ishave) { 
		
		tabPanel.add({
			closable: true,
			items:obj,
			layout:'fit',
		    iconCls: 'tabs', 
		    title: title 
		}).show();
	}
}






